package com.ruoyi.bussiness.controller;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.bussiness.domain.OwnerFundMonitor;
import com.ruoyi.bussiness.service.IOwnerFundMonitorService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 基金监控Controller
 * 
 * @author ruoyi
 * @date 2025-10-29
 */
@RestController
@RequestMapping("/bussiness/fund")
public class OwnerFundMonitorController extends BaseController
{
    @Autowired
    private IOwnerFundMonitorService ownerFundMonitorService;

    /**
     * 查询基金监控列表
     */
    @PreAuthorize("@ss.hasPermi('bussiness:fund:list')")
    @GetMapping("/list")
    public TableDataInfo list(OwnerFundMonitor ownerFundMonitor)
    {
        startPage();
        List<OwnerFundMonitor> list = ownerFundMonitorService.selectOwnerFundMonitorList(ownerFundMonitor);
        return getDataTable(list);
    }

    /**
     * 导出基金监控列表
     */
    @PreAuthorize("@ss.hasPermi('bussiness:fund:export')")
    @Log(title = "基金监控", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OwnerFundMonitor ownerFundMonitor)
    {
        List<OwnerFundMonitor> list = ownerFundMonitorService.selectOwnerFundMonitorList(ownerFundMonitor);
        ExcelUtil<OwnerFundMonitor> util = new ExcelUtil<OwnerFundMonitor>(OwnerFundMonitor.class);
        util.exportExcel(response, list, "基金监控数据");
    }

    /**
     * 获取基金监控详细信息
     */
    @PreAuthorize("@ss.hasPermi('bussiness:fund:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(ownerFundMonitorService.selectOwnerFundMonitorById(id));
    }

    /**
     * 新增基金监控
     */
    @PreAuthorize("@ss.hasPermi('bussiness:fund:add')")
    @Log(title = "基金监控", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OwnerFundMonitor ownerFundMonitor)
    {
        return toAjax(ownerFundMonitorService.insertOwnerFundMonitor(ownerFundMonitor));
    }

    /**
     * 修改基金监控
     */
    @PreAuthorize("@ss.hasPermi('bussiness:fund:edit')")
    @Log(title = "基金监控", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OwnerFundMonitor ownerFundMonitor)
    {
        return toAjax(ownerFundMonitorService.updateOwnerFundMonitor(ownerFundMonitor));
    }

    /**
     * 删除基金监控
     */
    @PreAuthorize("@ss.hasPermi('bussiness:fund:remove')")
    @Log(title = "基金监控", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ownerFundMonitorService.deleteOwnerFundMonitorByIds(ids));
    }
}
